package com.powernode.controller;

import com.netflix.hystrix.contrib.javanica.annotation.DefaultProperties;
import com.netflix.hystrix.contrib.javanica.annotation.HystrixCommand;
import com.netflix.hystrix.contrib.javanica.annotation.HystrixProperty;
import com.netflix.ribbon.proxy.annotation.Hystrix;
import com.powernode.client.ItemClient;
import com.powernode.commons.Result;
import com.powernode.service.OrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @AUTHOR X
 * @DATE 2021/10/28 22:20
 * @DESC
 */
@SuppressWarnings({"all"})
@RestController
@RequestMapping("/order")
@DefaultProperties(defaultFallback = "fallBack")
public class OrderController {
    /*@Autowired
    private OrderService orderService;*/

    /*@HystrixCommand(commandProperties = {
            @HystrixProperty(name = "execution.isolation.thread.timeoutInMilliseconds",value = "3000")
    })*/
    /*@HystrixCommand(commandProperties = {
            @HystrixProperty(name = "circuitBreaker.requestVolumeThreshold",value = "10"),
            @HystrixProperty(name = "circuitBreaker.sleepWindowInMilliseconds",value = "10000"),
            @HystrixProperty(name = "circuitBreaker.errorThresholdPercentage",value = "60")
    })*/
    @Autowired
    private ItemClient itemClient;

    @RequestMapping("items")
    public Result goodsItems(){
        return itemClient.items();
    }

    public Result fallBack(){
        return Result.build(1002,"对不起,当前服务忙,请稍后重试");
    }
}
